package com.hyper_yang.javase.supplement.learnClassInit;

public class Person {
    static {
        age = 100; // 正确，这里不同于实例初始化中的代码块，注意区别
        System.out.println("静态代码块1");
    }
    static int age; // 赋默认值
    static int num = 10; // 赋初始值 10

    public static void show() {
        System.out.println("Person show()");
    }

    static {
        age = 100;
        System.out.println("静态代码块1");
    }

    static {
        System.out.println("静态代码块2");
    }
}
// 继承关系下的类的初始化
class Student extends Person {
    static int b = 20;

    static {
        System.out.println("子类Student静态代码块1");
    }

    public static int getAge() {
        System.out.println("子类Student的getAge()静态方法");
        return 40;
    }
}